from django.db import models
from dvadmin.utils.models import CoreModel

class SalesStrategy(CoreModel):
    """销售策略模型"""
    STATUS_CHOICES = (
        ('pending', '待审批'),
        ('approved', '已通过'),
        ('rejected', '已驳回'),
    )
    
    name = models.CharField(max_length=100, verbose_name="策略名称")
    description = models.TextField(verbose_name="策略描述")
    start_date = models.DateField(verbose_name="开始日期")
    end_date = models.DateField(verbose_name="结束日期")
    status = models.CharField(
        max_length=20,
        choices=STATUS_CHOICES,
        default='pending',
        verbose_name="状态"
    )
    
    class Meta:
        db_table = "sales_strategy"
        verbose_name = '销售策略'
        verbose_name_plural = verbose_name
        ordering = ('-create_datetime',)

class SalesPerformance(CoreModel):
    """销售业绩模型"""
    sales_person = models.CharField(max_length=100, verbose_name="销售人员")
    period = models.DateField(verbose_name="业绩统计期")
    target_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="目标金额")
    actual_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="实际金额")
    achievement_rate = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="达成率")
    
    class Meta:
        db_table = "sales_performance"
        verbose_name = '销售业绩'
        verbose_name_plural = verbose_name
        ordering = ('-create_datetime',)

class MarketingPlan(CoreModel):
    """市场拓展计划模型"""
    title = models.CharField(max_length=100, verbose_name="计划标题")
    content = models.TextField(verbose_name="计划内容")
    target_market = models.CharField(max_length=100, verbose_name="目标市场")
    budget = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="预算")
    execution_status = models.CharField(
        max_length=20,
        choices=(
            ('planning', '计划中'),
            ('executing', '执行中'),
            ('completed', '已完成'),
            ('cancelled', '已取消'),
        ),
        default='planning',
        verbose_name="执行状态"
    )
    
    class Meta:
        db_table = "marketing_plan"
        verbose_name = '市场拓展计划'
        verbose_name_plural = verbose_name
        ordering = ('-create_datetime',)
